<template>
  <div class="app-container">
    <el-row :gutter="20" type="flex" justify="center" align="middle">
      <el-col :span="16" :xs="24"  style="background-color: rgb(6, 26, 72);border: 1px solid #0c1e4b;padding: 30px 40px 30px 40px">
        <div style="text-align: center;padding-bottom: 3%;font-size: 20px;font-weight:900;color:#5DCBFF">
           <span>算法参数配置</span>
        </div>
      <!-- 添加或修改对话框 -->
      <el-form ref="form":model="form" :rules="rules" label-width="80px" >
        <el-row v-loading="loading">
          <el-col :span="12">
            <el-form-item label="设备ID" prop="device_id">
              <el-input v-model="form.device_id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="巡检点ID" prop="inspection_point_id">
              <el-input v-model="form.inspection_point_id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="旋转角度" prop="ratio">
              <el-input v-model="form.ratio"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="缩放比例" prop="resize">
              <el-input v-model="form.resize"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="校准值" prop="calibration">
              <el-input v-model="form.calibration"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="其它备用" prop="other">
              <el-input v-model="form.other"/>
            </el-form-item>
          </el-col>
          </el-row>
      </el-form>
        <div class="dialog-footer" style="text-align: center;padding-top:2%">
        <el-button type="primary" @click="submitForm">设置配置参数</el-button>
      </div>
      </el-col>
    </el-row>
    </div>
</template>
<script>
import "@/assets/styles/robt-bg.css";
import {addalgorithmparam, getInfo} from "@/api/nssc/algorithmparam/algorithmparam";
export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 表单参数
      form: { },
      id:undefined,
      device_id:undefined,
      inspection_point_id:undefined,
      ratio:undefined,
      resize:undefined,
      calibration:undefined,
      other:undefined,
      // 表单校验
      rules: { }
    };
  },
  //初始化配置
  created() {
    this.getInfo();
  },
  methods: {
    /** 查询配置 */
    getInfo() {
      this.loading = true;
      getInfo().then(response => {
        this.form = response.data;
        this.loading = false;
      });
    }, //表单重置
    reset() {
      this.resetForm("form");
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
         if (valid) {
           addalgorithmparam(this.form).then(response => {
              this.$modal.msgSuccess("参数设置成功！");
              this.getInfo();
            });
         }
      });
    }
  }
};
</script>
